"use strict";

var HomepageApp = ( function(){

  //TODO: recognize first run, by saved settings from localStorage or...
  
  //TODO: use backbone view???
  
  var Favorites = new FavoritesCollection( null, {
        bookmarkTreeNodeId : 12 //TODO: make 12 load from localStorage
      , type               : 'folder' 
    } )
    , Apps      = new AppsCollection( null, { bookmarkTreeNodeId : 11 } ) //TODO: make 11 load from localStorage
    ; 
  
  var init = function() {
    
    //TODO: load state, last opened app - if not found use default first, choosen folder for favorites - if not found show settings page 
    
    //loadFavorites();
    
    //loadFrameApps)();
    
    //TODO: replace/rewrite below
    $('#recently-closed-menu-button').click(function(evt) {
      $('menu.recent-menu').fadeToggle('fast');
    });
    
    $(document).click(function(evt) {
      if(!$(evt.target).hasClass('favorites')) {
        $('menu.recent-menu').fadeOut('fast');
      }
    });
  
    init = function(){};
    
  }
  
  , loadFrameApps = function() {
    
  }
  
  , loadFavorites = function() {
    
  };
  
  return {
    init : init
  };
  
}() );
